package net.cooltain.warhammer.running.start;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import net.cooltain.warhammer.framework.constant.ConstantCardRace;
import net.cooltain.warhammer.running.entity.MotionPlayerZone;
import net.cooltain.warhammer.running.window.MainFrame;

public class GameStart {

	
	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		int millis = 100;
		// 游戏初始化
		MotionPlayerZone player1 = new MotionPlayerZone("Cool",ConstantCardRace.CARD_RACE_DWARF);
		MotionPlayerZone player2 = new MotionPlayerZone("Mike",ConstantCardRace.CARD_RACE_ORC);				
		GameBoardDouble board = new GameBoardDouble();
		board.loadUser(player1);
		board.loadUser(player2);
		MainFrame frame1 = new MainFrame(board, board.players[0]);
		MainFrame frame2 = new MainFrame(board, board.players[1]);
		
//		frame2.setVisible(false);
		Thread.sleep(millis);
		player1.deskZone.loadCardToDesk(GamePrepare.geneterDesk1(player1)); // 载入卡牌
		player2.deskZone.loadCardToDesk(GamePrepare.geneterDesk2(player2)); // 载入卡牌	
		
		// 游戏开始
		Thread.sleep(millis);
		board.startGame();
		// 玩家可以重抽7次牌
		
		// 玩家1第一回合开始
//		Thread.sleep(millis);
//		player1.toPhases1BegeningOfTurn();
//		Thread.sleep(millis);
//		player1.toPhases2KingdomPhases();
//		Thread.sleep(millis);
//		player1.toPhases3QuestPhases();
//		Thread.sleep(millis);
//		Thread.sleep(millis);
//		player1.toPhases4CapitalPhases();
		// 打一张发展卡到战场区
//		player1.handZone.playCardAsDeveloper(0, ConstantPlayZone.BATTLE_ZONE);
//		player1.battleZone.getCards().addAll(player1.handZone.getCards()); // 非法
//		player1.battleZone.getCards().get(2).setCorrupt(true); // 非法
//		player1.battleZone.getCards().get(5).setCorrupt(true); // 非法
		Thread.sleep(millis);
//		player2.consoleShowHand();
//		Thread.sleep(millis);
//		player1.toPhases5BattleFieldPhases();
//		Thread.sleep(millis);
//		player1.toPhases6EndOfTurn();
//		Thread.sleep(millis);
//		if(player2.handZone.getCardSize()>1){
//			frame2.setPreviewCard(player2.handZone.getCards().get(0));			
//		}
		//player1.deskZone.drawTopCard();
		
		// userInputOperate(board);
		frame1.reload();
		frame2.reload();
		while(true){
			Thread.sleep(500);
			frame1.reload();
			frame2.reload();
		}
		
	}

	
	public static void userInputOperate(GameBoardDouble board){
		
		while(true){
			
			System.out.print("请输入>>");
			BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
			try {
				String userIn = strin.readLine();
				
				if(userIn.equals("quit")){
					break;
				}else{
					System.out.println("ERROR:非法输入");					
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		System.out.println("== 游戏退出 ==");
		
	}

}
